package com.linux.huhx.thread3.threadState_1;

/**
 * @Author: huhx
 * @Date: 2017-10-31 下午 2:51
 * STATE: TIMED_WAITING
 */
public class StateRun2 {

    public static void main(String[] args) throws InterruptedException {
        MyThread myThread = new MyThread();
        myThread.start();
        Thread.sleep(1000);
        System.out.println("main " + myThread.getState()); // main TIMED_WAITING
    }

    static class MyThread extends Thread {
        @Override
        public void run() {
            try {
                System.out.println("begin sleep.");
                Thread.sleep(10 * 1000);
                System.out.println("end sleep." + Thread.currentThread().getState()); // RUNNABLE
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
/*
begin sleep.
main TIMED_WAITING
end sleep.RUNNABLE
 */